{js:my97date}
{set:$timeList=goods_class::getGoodsNoRangeTime($this->goodsList[0]['goods_no']);}
{set:$user = Api::run('getMemberInfo')}
<!--时间类商品 开始-->
<div class="wrap_box" id="preorderTimeBox">
    <h3>
        <span class="orange">预订信息</span>
    </h3>

    <table width="100%" class="border_table m_10"  border="1" cellspacing="0" cellpadding="0" style="border-collapse: collapse;">
        <colgroup>
            <col width="180px" />
            <col />
        </colgroup>

        <tbody>
        <tr>
            <th><label>预订规格</label></th>
            <td style="padding: unset">
                <table width="100%" class="cart_table t_c" border="1" cellspacing="0" cellpadding="0" style="border-collapse: collapse;border-width:0px; border-style:hidden;">
                    <colgroup>
                        <col width="115px" />
                        <col />
                        <col width="80px" />
                    </colgroup>

                    <thead>
                    <tr>
                        <th>图片</th>
                        <th>商品名称</th>
                        <th>赠送积分</th>
                    </tr>
                    </thead>

                    <tbody>
                    <!-- 商品展示 开始-->
                    {foreach:items = $this->goodsList}
                    <tr>
                        <td><img src="{url:/pic/thumb/img/$item['img']/w/66/h/66}" width="66px" height="66px" alt="{$item['name']}" title="{$item['name']}" /></td>
                        <td class="t_l">
                            <a href="{url:/site/products/id/$item['goods_id']}" class="blue">{$item['name']}</a>
                            {if:isset($item['spec_array'])}
                            <p>
                                {set:$spec_array=goods_class::show_spec($item['spec_array']);}
                                {foreach:items=$spec_array item=$specValue key=$specName}
                                {$specName}：{$specValue} &nbsp&nbsp
                                {/foreach}
                            </p>
                            {/if}
                        </td>
                        <td>{$item['point']}</td>
                    </tr>
                    {/foreach}
                    <!-- 商品展示 结束-->
                    </tbody>
                </table>
            </td>
        </tr>
        <tr>
            <th><label>服务时间</label></th>
            <td>
                <input class="normal" pattern='date' type="text" name="preorder[start_time]" onfocus='WdatePicker({minDate:minDataSetting(this,"start"),onpicked:perOrderDoAccount,opposite:true,disabledDates:{echo:JSON::encode($timeList)}})' value="" />
                <input class="normal" pattern='date' type="text" name="preorder[end_time]" onfocus='WdatePicker({minDate:minDataSetting(this,"end"),onpicked:perOrderDoAccount,opposite:true,disabledDates:{echo:JSON::encode($timeList)}})' value="" />
            </td>
        </tr>
        <tr>
            <th><label>预订数量</label></th>
            <td>
                <input class="small" pattern='int' type="text" name="preorder[num]" value="" onchange="perOrderDoAccount()"/>
            </td>
        </tr>
        </tbody>

        <tfoot>
        <th>价格详情：</th>
        <td style="padding: unset">
            <table width="100%" class="border_table m_10" id="dayPriceList" border="1" cellspacing="0" cellpadding="0" style="border-collapse: collapse;border-width:0px; border-style:hidden;"></table>
            <script id="dayPriceListTemplate" type='text/html'>
                <tr>
                    <td>预定时间</td><td>原价</td><td>预定价格</td><td>预定数量</td><td>总价</td>
                </tr>
                <%for(var item in templateData){%>
                <tr>
                    <td><%=templateData[item]['day']%></td>
                    <td>￥ <%=templateData[item]['sum']%></td>
                    <td>￥ <%=templateData[item]['price']%></td>
                    <td><%=templateData[item]['num']%></td>
                    <td>￥ <%=templateData[item]['totalPrice']%></td>
                </tr>
                <%}%>
                <tr>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td>￥ <span id="allPrice"></span></td>
                </tr>
            </script>
        </td>
        </tfoot>
    </table>
</div>

<div class="wrap_box" id="preorderUserBox">
    <h3>
        <span class="orange">客户信息</span>
    </h3>

    <table width="100%" class="border_table m_10">
        <colgroup>
            <col width="180px" />
            <col />
        </colgroup>

        <tbody>
        <tr>
            <th><label>姓名</label></th>
            <td><input class="normal" pattern='required' type="text" name="preorder[name]" value="{$user['true_name']}"/>
            </td>
        </tr>
        <tr>
            <th><label>手机</label></th>
            <td><input class="normal" pattern='mobi' type="text" name="preorder[mobile]" value="{$user['mobile']}"/>
            </td>
        </tr>
        <tr>
            <th><label>邮箱</label></th>
            <td><input class="normal" pattern='email' type="text" name="preorder[email]" value="{$user['email']}"/>
            </td>
        </tr>
        </tbody>
    </table>
</div>
<!--时间类商品 结束-->

<script>
    $(function () {
        orderFormInstance.goodsSum = 0;
        orderFormInstance.doAccount();
    });

    //计算价格
    function perOrderDoAccount(){
        var start_time = $(":input[name='preorder[start_time]']").val();
        var end_time   = $(":input[name='preorder[end_time]']").val();
        var num        = $(":input[name='preorder[num]']").val();
        if (start_time != '' && end_time != '' && num != ''){
            $("#dayPriceList").html("加载中...");
            $.getJSON(creatUrl("/simple/getGoodsNoRangeTimePrice"),{"start_time":start_time,"end_time":end_time,"num":num,"goods_no":"{echo:$this->goodsList[0]['goods_no']}"},function(content)
            {
                if(content.isError == true)
                {
                    alert(content.message);
                    $(":input[name='preorder[end_time]']").val('');
                    $(":input[name='preorder[end_time]']").focus();
                    return;
                }
                //详情模版渲染
                var dayPriceListHtml = template.render('dayPriceListTemplate',{'templateData':content.list});
                $('#dayPriceList').html(dayPriceListHtml);
                $('#allPrice').html(content.allPrice);
                //结算金额
                orderFormInstance.goodsSum = content.allPrice;
                orderFormInstance.doAccount();
            });
        }
    }

    //时间关联设置
    function minDataSetting(self,type) {
        //第一个开始时间
        if (type == 'start'){
            return '%y-%M-%d';
        }
        //结束时间
        if (type == 'end'){
            return $('input[name="preorder[start_time]"]').val();
        }
    }
</script>